package com.atguigu.web;

import com.atguigu.pojo.*;
import com.atguigu.service.*;
import com.atguigu.service.impl.*;
import com.atguigu.utils.WebUtils;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;

public class HeartbeatServlet  extends BaseServlet {
    ServerService serverService=new ServerServiceImpl();
    protected void heartbeat(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        List<Server> servers=serverService.queryServers();
        if(servers==null){
            response.getWriter().write("error");
        }else {
            response.getWriter().write("success");
        }
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println(Thread.currentThread().getStackTrace()[1].getFileName()+":"
                +Thread.currentThread().getStackTrace()[1].getLineNumber()+":"
                +"已经进入doget方法,"+request.getParameter("action")+" 是action名");
        doPost(request,response);//把dopost方法优化到baseServlet抽象类中去了,使得可以按照request action执行特定的方法
        //由于action判断行为在dopost中,所以在doget中执行一下dopost就可以执行判断了,从而执行特定的方法了.
    }
}

